package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Mobile   string `gorm:"type:varchar(11);not null"`
	Password string `gorm:"type:varchar(40)"`
	Captcha  string `gorm:"type:varchar(40)"`
	SendSms  string `gorm:"type:varchar(40)"`
}

func (u *User) LoginUser(db *gorm.DB, mobile string) error {
	return db.Debug().Where("mobile=?", mobile).FirstOrCreate(u).Error
}

func (u *User) FindUserByName(db *gorm.DB, id int64) error {
	return db.Debug().Where("id=?", id).First(u).Error
}
